function AoTParam= parseConfigFile(path,filename)
%% Function to read parameters for one root volume of AoT
%% Target file contains functions such as the size and orientation of the 
%% volume.
pFile = fopen([path '/' filename],'r');
if pFile ==-1
    disp(['Failed to open config file ' path '/' filename]);
    AoTParam = -1;
    return;
end
 
i_line = 0;
txt_line = fgetl(pFile);
while 1
    txt_line = fgetl(pFile);
   if  isempty(txt_line) | (txt_line ==-1)
    break;
   end
    if (txt_line(1)=='%') % the sign of comment
        continue;
    end
    data = sscanf(txt_line,'%f,');
    i_line = i_line+1;
    switch i_line
        case 1 % root volume size
           AoTParam.size = data';
        case 2 % lower corner position
            AoTParam.corner = data';
        case 3 % aspect ratio limit, lower bound
            AoTParam.asp_low_limit = data';
        case 4 % aspect ratio limit, upper bound
            AoTParam.asp_high_limit = data';
        case 5 % rotation matrix, columwise lumped
            AoTParam.rotationMatrix = reshape(data,3,3);
        case 6 % scale: world to tan
            AoTParam.swt = data;
        case 7 % scale: tan to plane
            AoTParam.stp = data;
        otherwise
            disp('unknown parameter for root vol config file ignored')
    end
end
fclose(pFile);
end